package com.cn.demo4.service.impl;

import com.cn.demo4.dao.LayoutDao;
import com.cn.demo4.dao.impl.LayoutDaoImpl;
import com.cn.demo4.model.LayoutModel;
import com.cn.demo4.service.ILayoutService;

import java.util.List;

public class LayoutServiceImpl implements ILayoutService {
    @Override
    public List<LayoutModel> findAll(LayoutModel layoutModel) {
        LayoutDao layoutDao = new LayoutDaoImpl();
        return layoutDao.findAll(layoutModel);
    }

    @Override
    public String add(LayoutModel layoutModel) {
        LayoutDao layoutDao = new LayoutDaoImpl();
        return layoutDao.add(layoutModel) == 1 ? "success" : "error";
    }

    @Override
    public LayoutModel findById(Integer id) {
        LayoutDao layoutDao = new LayoutDaoImpl();
        return layoutDao.findById(id);
    }

    @Override
    public String update(LayoutModel layoutModel) {
        LayoutDao layoutDao = new LayoutDaoImpl();
        return layoutDao.update(layoutModel) == 1 ? "success" : "error";
    }

    @Override
    public int del(Integer id) {
        LayoutDao layoutDao = new LayoutDaoImpl();
        return layoutDao.del(id);
    }

    @Override
    public List<LayoutModel> getLayoutModelListForLayout() {
        LayoutDao layoutDao = new LayoutDaoImpl();
        return layoutDao.getLayoutModelListForLayout();
    }

    @Override
    public int getCount(LayoutModel layoutModel) {
        LayoutDao layoutDao = new LayoutDaoImpl();
        return layoutDao.getCount(layoutModel);
    }
}
